//
//  BusinessViewController.m
//  paiduibao
//
//  Created by sun qiang on 13-4-15.
//  Copyright (c) 2013年 paiduibao. All rights reserved.
//

#import "BusinessViewController.h"

@interface BusinessViewController ()
{
    UITableView* pBusinessListView;
}
@end

@implementation BusinessViewController
@synthesize pBankIndex;
@synthesize pTableView;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        pBusinessListView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height) style:UITableViewStylePlain];
        pBusinessListView.delegate = self;
        pBusinessListView.dataSource = self;
        [self.view addSubview:pBusinessListView];
    }
    return self;
}
- (void)dealloc
{
    
    [super dealloc];
}
- (void)viewDidLoad
{

    self.title = @"业务选择";
    [super viewDidLoad];
	// Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}

// Row display. Implementers should *always* try to reuse cells by setting each cell's reuseIdentifier and querying for available reusable cells with dequeueReusableCellWithIdentifier:
// Cell gets various attributes set automatically based on table (separators) and data source (accessory views, editing controls)

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell* retCell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"bankcell"]autorelease];
    retCell.textLabel.text = [NSString stringWithFormat: @"业务_%d",indexPath.row];
    
    return retCell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self sendSMS];
}
- (void)sendSMS {
	
	BOOL canSendSMS = [MFMessageComposeViewController canSendText];
	NSLog(@"can send SMS [%d]", canSendSMS);
	if (canSendSMS) {
        
		MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
		picker.messageComposeDelegate = self;
		picker.navigationBar.tintColor = [UIColor blackColor];
		picker.body = @"test";
        //yuezi phone
        picker.recipients = [NSArray arrayWithObject:@"18210283318"];
        //my phone
		//picker.recipients = [NSArray arrayWithObject:@"15911070623"];
		[self presentModalViewController:picker animated:YES];
		[picker release];
	}
}

- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result {
	
	// Notifies users about errors associated with the interface
	switch (result) {
		case MessageComposeResultCancelled:
			if (DEBUG) NSLog(@"Result: canceled");
			break;
		case MessageComposeResultSent:
			if (DEBUG) NSLog(@"Result: Sent");
			break;
		case MessageComposeResultFailed:
			if (DEBUG) NSLog(@"Result: Failed");
			break;
		default:
			break;
	}
	[self dismissModalViewControllerAnimated:YES];
}

@end
